program define fx2, rclass
   version 15.1
	syntax varlist [if] [pweight], t1(varname) t2(varname) [OPTS(str) ///
	   ALLFIVE LABEL1(str) LABEL2(str) NODRAW]
	marksample touse
		
	if "`weight'" ~= "" {
	   local wt [`weight'`exp']
   }			
	if "`label1'"~="" & "`label2'"~="" {  // labels for legend, if desired
	   local label1 label(`label1')
		local label2 label(`label2')
	}
	else {
	   local legend legend(off)
   }		
	
	table axn5 `t1' if `touse' `wt', c(mean `varlist' n `varlist') format(%4.2f)
	table axn5 `t2' if `touse' `wt', c(mean `varlist' n `varlist') format(%4.2f)
	tempname fx1 fx2
	local gopts scheme(s1mono) plotregion(style(none)) mlabel format(%3.0f) `legend'
			
	* Distinguish all five actions
	if "`allfive'" ~= "" {
	
	   forvalues i=1/2 {
		   reg `varlist' i.axn5##i.`t`i'' if `touse' `wt', robust
		   margins r.`t`i'', at(axn5=(0 1 2 3 4))		
		   mat `fx`i'' = r(table)
		   mat colnames `fx`i'' = c0 c1 c2 c3 c4
      }		
		
		if "`nodraw'" == "" {
		   coefplot ///
				(matrix(`fx1'[1,]), ci("`fx1'[5,] `fx1'[6,]") msymbol(O) mlabpos(10))  ///
			   (matrix(`fx2'[1,]), ci("`fx2'[5,] `fx2'[6,]") msymbol(Oh) mlabpos(10)), ///			   
				coeflabel(c0="No Action" c1="Cut 5%, Cost 10%" c2="Cut 5%, Cost 4%" ///
               c3="Cut 25%, Cost 10%" c4="Cut 25%, Cost 4%") `gopts' `opts'
		}
		
   }
	else {
	   forvalues i=1/2 {
		
			* Estimates if no action
			reg `varlist' i.`t`i'' if `touse' & axn5==0 `wt', robust
			margins r.`t`i''
			mat `fx`i'' = r(table)		
			
			* 5% reduction in emissions. Average over prices
			reg `varlist' i.axn5#i.`t`i'' if `touse' & (axn5==1 | axn5==2) `wt', robust
			margins r.`t`i'', asbalanced // equal weight over prices
			mat `fx`i'' = `fx`i'', r(table)		
			
			* 25% reduction in emissions. Average over prices.
			reg `varlist' i.axn5#i.`t`i'' if `touse' & (axn5==3 | axn5==4) `wt', robust
			margins r.`t`i'', asbalanced // equal weight over prices
			mat `fx`i'' = `fx`i'', r(table)
			
			mat colnames `fx`i'' = none low high
		
		}
		
		if "`nodraw'" == "" {
		   coefplot ///
			   (matrix(`fx1'[1,]), ci("`fx1'[5,] `fx1'[6,]") msymbol(O) mlabpos(10))  ///
			   (matrix(`fx2'[1,]), ci("`fx2'[5,] `fx2'[6,]") msymbol(Oh) mlabpos(10)), ///	
			   coeflabel(none = "No Action" low = "Cut 5%" high = "Cut 25%") ///
			   `gopts' `opts' 
		}
		
	}
	
	mat list `fx1'
	mat list `fx2'
	return matrix fx1 = `fx1'
	return matrix fx2 = `fx2'
	
end
